home *** CD-ROM | disk | FTP | other *** search
/ Imaginext Pirate Activity / ImaginextPirateActivityCD.iso / Pirate Raider / piratedemo.dxr / globallingo_36_Sprite Flash Behavior.ls < prev    next >
Encoding:
Text File  |  2003-05-30  |  1.7 KB  |  68 lines

  1. property flashSymbol, flashMember, flashSound, flashTime, flashDelay, flashList, nonFlashMember, sprt
  2. global FlashMgr, SndMgr
  3.  
  4. on getPropertyDescriptionList
  5.   d = [:]
  6.   lst = []
  7.   if the number of member "flashField" <> -1 then
  8.     tmpList = value(the text of field "flashField")
  9.   else
  10.     tmpList = []
  11.   end if
  12.   repeat with i = 1 to count(tmpList)
  13.     add(lst, getPropAt(tmpList, i))
  14.   end repeat
  15.   addProp(d, #flashSymbol, [#default: EMPTY, #format: #symbol, #range: lst, #comment: "Flash symbol"])
  16.   addProp(d, #flashMember, [#default: EMPTY, #format: #string, #comment: "Flash member"])
  17.   addProp(d, #flashSound, [#default: EMPTY, #format: #string, #comment: "Flash sound"])
  18.   addProp(d, #flashDelay, [#default: 10, #format: #integer, #comment: "Flash delay (in ticks)"])
  19.   return d
  20. end
  21.  
  22. on beginSprite me
  23.   sprt = sprite(me.spriteNum)
  24.   flashList = value(the text of field "flashField")[flashSymbol]
  25.   nonFlashMember = sprt.member
  26.   FlashMgr.register(sprt, flashSymbol, flashDelay, flashList)
  27. end
  28.  
  29. on endSprite me
  30.   FlashMgr.unregister(sprt, flashSymbol)
  31. end
  32.  
  33. on flash me
  34.   if flashMember = EMPTY then
  35.     if sprt.visible then
  36.       sprt.visible = 0
  37.     else
  38.       sprt.visible = 1
  39.       playFlashSound()
  40.     end if
  41.   else
  42.     if sprt.member = nonFlashMember then
  43.       sprt.member = flashMember
  44.       playFlashSound()
  45.     else
  46.       sprt.member = nonFlashMember
  47.     end if
  48.   end if
  49. end
  50.  
  51. on playFlashSound me
  52.   if flashSound <> EMPTY then
  53.     sym = symbol(#flash & flashSymbol)
  54.     SndMgr.killSfxId(sym)
  55.     SndMgr.sfx(flashSound, VOID, sym)
  56.   end if
  57. end
  58.  
  59. on killFlash me
  60.   if flashMember = EMPTY then
  61.     sprt.visible = 1
  62.   else
  63.     sprt.member = nonFlashMember
  64.   end if
  65.   sym = symbol(#flash & flashSymbol)
  66.   SndMgr.killSfxId(sym)
  67. end
  68.